{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Bayesian Statistics Made Simple\n",
    "===\n",
    "\n",
    "Code and exercises from my workshop on Bayesian statistics in Python.\n",
    "\n",
    "Copyright 2016 Allen Downey\n",
    "\n",
    "MIT License: https://opensource.org/licenses/MIT"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# If we're running on Colab, install empiricaldist\n",
    "# https://pypi.org/project/empiricaldist/\n",
    "\n",
    "import sys\n",
    "IN_COLAB = 'google.colab' in sys.modules\n",
    "\n",
    "if IN_COLAB:\n",
    "    !pip install empiricaldist"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "import seaborn as sns\n",
    "sns.set_style('white')\n",
    "sns.set_context('talk')\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from empiricaldist import Pmf"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Working with Pmfs\n",
    "\n",
    "Create a Pmf object to represent a six-sided die."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "d6 = Pmf()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A Pmf is a map from possible outcomes to their probabilities."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "for x in [1,2,3,4,5,6]:\n",
    "    d6[x] = 1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Initially the probabilities don't add up to 1."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>probs</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "1    1\n",
       "2    1\n",
       "3    1\n",
       "4    1\n",
       "5    1\n",
       "6    1\n",
       "dtype: int64"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d6"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`normalize` adds up the probabilities and divides through.  The return value is the total probability before normalizing."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d6.normalize()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now the Pmf is normalized."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>probs</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.166667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.166667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.166667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.166667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.166667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.166667</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "1    0.166667\n",
       "2    0.166667\n",
       "3    0.166667\n",
       "4    0.166667\n",
       "5    0.166667\n",
       "6    0.166667\n",
       "dtype: float64"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d6"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And we can compute its mean (which only works if it's normalized)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.5"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d6.mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`choice` chooses a random values from the Pmf."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([5, 1, 3, 1, 4, 5, 1, 5, 4, 3])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d6.choice(size=10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`bar` plots the Pmf as a bar chart"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "def decorate_dice(title):\n",
    "    \"\"\"Labels the axes.\n",
    "    \n",
    "    title: string\n",
    "    \"\"\"\n",
    "    plt.xlabel('Outcome')\n",
    "    plt.ylabel('PMF')\n",
    "    plt.title(title)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZ8AAAEtCAYAAADX4G3qAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAbiklEQVR4nO3dffxnU7338dcwSJmZ3NbJSQz1mUuJ3DzSI0kddKHcHESXLunRjUqpIToVlxOV2+ooFeqRUbkYh0jquDtu6yiHuDoln0zNJCc0SuZHCDPXH2t/+fr6/n7z/d3M2tNvXs/H4/fY81t7rbXXjuZt7b323lOWLFmCJEk1rdT2ACRJKx7DR5JUneEjSarO8JEkVWf4SJKqM3wkSdVNbXsA0mQSEasBhwD7A7OAJcCvgXOBMzPzwRaH9wwRsQBYkJk7NL9fC2yYmRu2NiitMJz5SBMkItYHbgZOAe4GPg58ErgD+CxwS0REeyNcqs8AH2l7EFoxTPEhU2n8ImJV4D+AAPbIzKt79r8a+AHwIPCKzPxL/VE+U+/MR6rJmY80Md4BbAV8t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Pvpbxt4e3d912ah2EPAx4DrhzTmT7tZsoii0MjYo2uY0wHzqesnhvkPpjkzEcai8xcHBF7AZcAl0XEd4CrKcGxLXAAcBewR2Y+1DQ7l7Ii7bKI+DZlJvNe4Lc93S9stkdExL9l5iWUV/f8BLipWV22CHgP5V7QUU39Q5sx/GdEfAUYAt5OeRj20Mz88zjP+fGI+BAlaH4aEV+nLFx4D+V+0gE995GkYTnzkcYoM+8Dtqc8C/MiyuW1k4DNKYGwVWb+oqvJV4BjKG89+BLlst1ewM97uj6P8ozNO4ETm2P9EngNZZnzkZSHPO8BtuscIzNvBF4L3EJ5YPTTlHDYMzO/NEHnfCFl6fXdlHs/x1GCcPfMPHcijqEVg284kCRV58xHklSd4SNJqs7wkSRVZ/hIkqozfCRJ1Rk+kqTqDB9JUnWGjySpOsNHklSd4SNJqu7/A+M0bY30NjHoAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "d6.bar()\n",
    "decorate_dice('One die')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`d6.add_dist(d6)` creates a new `Pmf` that represents the sum of two six-sided dice."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>probs</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.027778</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.055556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.083333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.111111</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.138889</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.166667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.138889</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.111111</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0.083333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>0.055556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0.027778</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "2     0.027778\n",
       "3     0.055556\n",
       "4     0.083333\n",
       "5     0.111111\n",
       "6     0.138889\n",
       "7     0.166667\n",
       "8     0.138889\n",
       "9     0.111111\n",
       "10    0.083333\n",
       "11    0.055556\n",
       "12    0.027778\n",
       "dtype: float64"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "twice = d6.add_dist(d6)\n",
    "twice"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Exercise 1:**  Plot `twice` and compute its mean."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6.999999999999998"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      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6x68EnKZbsDgFs7ml5IecbmbcAp9Vw/AF5Omeb8AcpDnsuB3VvnyMwlwCuBmygPjH6UEg77Z+Yn+/SZv0SZen035d7PiZQg3C8zv9iPc2jD4AoHkqTGOfKRJDXO8JEkNc7wkSQ1zvCRJDXO8JEkNc7wkSQ1zvCRJDXO8JEkNc7wkSQ1zvCRJDXu/wNyleI0S5J80QAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "twice.bar()\n",
    "decorate_dice('Two dice')\n",
    "twice.mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Exercise 2:** Suppose I roll two dice and tell you the result is greater than 3.\n",
    "\n",
    "Plot the `Pmf` of the remaining possible outcomes and compute its mean."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "7.393939393939394"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZ8AAAEtCAYAAADX4G3qAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nO3deZzVVf3H8RcIKgajgmv+3Ab0Q5S7/kRDQ8Ncc8OFNrNfhpqm4YaZaW6ZiJV7YCVuCeSCigruqIWampWhH0XBLVxQckZFReD3xzlXvn29c+fOzJ3znYH38/GYx3fmfM8533OH4X7uWb7n22Xx4sWIiIik1LXoBoiIyLJHwUdERJJT8BERkeQUfEREJDkFHxERSU7BR0REkutWdAOkczOzccB3q8h6lbsf2r6tqZ6ZvQo86+5D4s8PA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Pqecj0jrXEFaUDSfMdZSzD2GY6qz480LCXNGnzKwbYbL/hQrXmgvMB/rlT5jZCcBahBVqEHZZ+Ey2eHylwjWqMTse33P3e3Lt2IYwFzY/X0ikHPV8RFpnHGGJ8S/N7Gv5k2a2OTAWmAWMismvh1PWI5N1byDfe1oYj10B4vDYXcAeZrZu5hqrEhYb9HX31wm7LXw7O+8Sb4Y9DvgIuLtVr3SJxwmLLI4xs56Za9QBEwmr56qZBxNRz0ekNdx9kZntB9wKTDGzm4D7CIFjIPAt4GVgH3d/Lxa7nrAibYqZXUvoyQwHXspV/1Y8nmhmd7r7rYStex4FHouryxqAHxDmgk6N+Y+JbfirmV0GNALfJtwMe4y7/6eNr3mBmf2IEGieNLPfERYu/IAwn/St3DySSJPU8xFpJXd/A9iRcC/M5wnDa6OAzQgBYSt3/1emyGXA6YRdDy4mDNvtBzydq3o84R6b7wHnxWs9A2xHWOZ8EuEmzznAoNI13H068GXgCcINo2cTgsO+7n5xjV7zjYSl168S5n7OIgTCvd39+lpcQ5YN2uFARESSU89HRESSU/AREZHkFHxERCQ5BR8REUlOwUdERJJT8BERkeQUfEREJDkFHxERSU7BR0REklPwERGR5P4fQfLjK68Am60AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "twice_gt3 = d6.add_dist(d6)\n",
    "twice_gt3[2] = 0\n",
    "twice_gt3[3] = 0\n",
    "twice_gt3.normalize()\n",
    "\n",
    "twice_gt3.bar()\n",
    "decorate_dice('Two dice, greater than 3')\n",
    "twice_gt3.mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Bonus exercise:** In Dungeons and Dragons, the amount of damage a [goblin](https://www.dndbeyond.com/monsters/goblin) can withstand is the sum of two six-sided dice.  The amount of damage you inflict with a [short sword](https://www.dndbeyond.com/equipment/shortsword) is determined by rolling one six-sided die.\n",
    "\n",
    "Suppose you are fighting a goblin and you have already inflicted 3 points of damage.  What is your probability of defeating the goblin with your next successful attack?\n",
    "\n",
    "Hint: `Pmf` provides comparator functions like `gt_dist` and `le_dist`, which compare two distributions and return a probability."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZ8AAAEtCAYAAADX4G3qAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAdsUlEQVR4nO3deZRdVZn38W8YRUnCbAstSgg+aZFBhlfoF2mkGWSQwYDAiy/iehWwQeiAgCKKCooMSqPIIC4JCEoQZOhoMymTGkRQWmn0ETRhUJBEAymRBEjy/rHPJZfLreJW1c25SeX7WavWqdpn7332LRb1yz5nn3NGLVy4EEmS6rRcrwcgSVr2GD6SpNoZPpKk2hk+kqTaGT6SpNoZPpKk2q3Q6wFIi1NETAY+0EHVSzPz0EH2/Qbg6cx8bpDt7gZWy8wJA9T5InBiS/HzwF+AnwJnZuY9gzmutCQxfDTSXQTc2vTzO4HDgK8DdzWV/34wnUbE3sC3gLcAgwqfQfoMi8a2CvBmSpj+JCIOzMxrFuOxpcXG8NGIlpnTgGmNnyNiBUr4TMvMy4fR9bbA6GEOrxM3ZebdzQUR8WXgbuCyiPhpZj5RwzikrvKaj7SUycy/AB8BXgt8tMfDkYbEmY/UIiJ2BD4F/C9gAWXm9JnM/Gm1/0rggKr6ExFxU2a+u9p3EPBvwKbAa4DHgSur9i90a4yZeWtE/Bl4N3BS09hf9fjVNadG+SnARsDvgGOBnwPnAO8F5gHfBY7LzHlV21HAkcChwATK35DpwMWZ+eXmMUbEe4BPAxsDfwLOBLYHtmq+3hURmwKnVftWAu4FPpuZPxz+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ANsBR0fE6ykznm81gqeqMxc4C1gF2Lmp27nAjU0//67avnR6rpq5zaAEFZRgGVfVWT0i1oqItaq+/xPYPCL+caifU8sWZz7S4M2khMrrO6jbmPH8acBaA1sTWJWXv3kTgMx8ACAi3tEoatP+N9X2TU1lf8nM5vBsfP9US9v5LPpH6obV9qzqq503UpadSwNy5iMNUjUj+AmwdUS8pr961YKD7YA/ZOZAp+iWf5VDNvYvGKDOQDOrxv/nzzeV9TdrG2gFUmMcn6LMotp9/XaA9tJLnPlIQ/MtyoqywyjXOtrZm3Ka6tTq5/mUa0UviYgVKBf7fz/AsWYBzwGveGV6RHwM+AfKCjUoT1l4RbVq+9gAx+jEjGr7t8y8tWUcW1OuhT3X2khqx5mPNDSTKUuMvxgRu7TujIjNga8D04Ezq+Iny65YpanqXkDr7Gl+tV0OoDo9djOwe0S8sekYq1MWG2yYmU9Snrbw/ubrLtXNsMcC84BbhvRJF7mXssji6IhYtekYY4CrKKvnOrkOJjnzkYYiMxdExL7ADcCNEfE94EeU4NgGOBh4FNg7M/9WNfsOZUXajRFxOWUmcxjwSEv3M6vt8RHxX5l5A+XRPT8D7qlWl80BPky5FnRyVf/oagw/j4jzgT7g/ZSbYY/OzKeH+ZlfiIiPUoLmFxHxDcrChQ9Tricd3HIdSeqXMx9piDLzz8D2lHth1qWcXjsT2IwSCFtm5v80NTkfOIXy1IOvUk7b7Qs80NL1lZR7bD4InFEd6zfAtpRlzidQbvJ8AtiucYzMnAb8b+A+yg2jp1HCYZ/M/GqXPvM1lKXXj1Ou/ZxKCcK9MvM73TiGlg0+4UCSVDtnPpKk2hk+kqTaGT6SpNoZPpKk2hk+kqTaGT6SpNoZPpKk2hk+kqTaGT6SpNoZPpKk2v1/eTs5g4kwPAIAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "damage = d6.add_dist(3)\n",
    "damage.bar()\n",
    "decorate_dice('Total Damage')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.5"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "hit_points = d6.add_dist(d6)\n",
    "damage.ge_dist(hit_points)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### The cookie problem\n",
    "\n",
    "`Pmf.from_seq` makes a `Pmf` object from a sequence of values.\n",
    "\n",
    "Here's how we can use it to create a `Pmf` with two equally likely hypotheses."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>probs</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Bowl 1</th>\n",
       "      <td>0.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Bowl 2</th>\n",
       "      <td>0.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Bowl 1    0.5\n",
       "Bowl 2    0.5\n",
       "dtype: float64"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cookie = Pmf.from_seq(['Bowl 1', 'Bowl 2'])\n",
    "cookie"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we can update each hypothesis with the likelihood of the data (a vanilla cookie)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.625"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cookie['Bowl 1'] *= 0.75\n",
    "cookie['Bowl 2'] *= 0.5\n",
    "cookie.normalize()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And display the posterior probabilities."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>probs</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Bowl 1</th>\n",
       "      <td>0.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Bowl 2</th>\n",
       "      <td>0.4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Bowl 1    0.6\n",
       "Bowl 2    0.4\n",
       "dtype: float64"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cookie"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Exercise 3:** Suppose we put the first cookie back, stir, choose again from the same bowl, and get a chocolate cookie.  \n",
    "\n",
    "What are the posterior probabilities after the second cookie?\n",
    "\n",
    "Hint: The posterior (after the first cookie) becomes the prior (before the second cookie)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>probs</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Bowl 1</th>\n",
       "      <td>0.428571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Bowl 2</th>\n",
       "      <td>0.571429</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Bowl 1    0.428571\n",
       "Bowl 2    0.571429\n",
       "dtype: float64"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "cookie['Bowl 1'] *= 0.25\n",
    "cookie['Bowl 2'] *= 0.5\n",
    "cookie.normalize()\n",
    "cookie"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Exercise 4:** Instead of doing two updates, what if we collapse the two pieces of data into one update?\n",
    "\n",
    "Re-initialize `Pmf` with two equally likely hypotheses and perform one update based on two pieces of data, a vanilla cookie and a chocolate cookie.\n",
    "\n",
    "The result should be the same regardless of how many updates you do (or the order of updates)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>probs</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Bowl 1</th>\n",
       "      <td>0.428571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Bowl 2</th>\n",
       "      <td>0.571429</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Bowl 1    0.428571\n",
       "Bowl 2    0.571429\n",
       "dtype: float64"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "cookie = Pmf.from_seq(['Bowl 1', 'Bowl 2'])\n",
    "cookie['Bowl 1'] *= 0.75 * 0.25\n",
    "cookie['Bowl 2'] *= 0.5 * 0.5\n",
    "cookie.normalize()\n",
    "cookie"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
